package com.yanqu.road.server.cmd.monopolymarket;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.pb.monopolymarket.MonopolyMarketProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.monopolymarket.MonopolyMarketMgr;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

/**
 * @Description
 * @Author cwq
 * @Data 2021/8/12 17:08
 */
@Cmd(code = Protocol.C_CROSS_MONOPOLY_MARKET_GET_USER_DATA, desc = "登陆获取榷场玩家数据")
public class CrossMonopolyMarketGetUserDataCmd extends CrossCommand {

    private long userId;
    private UserBaseInfo userBaseInfo;
    private int decorationClass;
    private int decorationOverTime;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        MonopolyMarketProto.MonopolyMarketCheckUserDataToCrossReqMsg reqMsg = MonopolyMarketProto.MonopolyMarketCheckUserDataToCrossReqMsg.parseFrom(packet.getBytes());
        userId = packet.getPlayerId();
        if(reqMsg.hasPlayerInfo()){
            userBaseInfo = PlayerBasePb.parseToUserBaseInfo(reqMsg.getPlayerInfo());
        }
        decorationClass = reqMsg.getDecorationClass();
        decorationOverTime = reqMsg.getDecorationOverTime();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        MessageHelper.sendPacket(serverId, userId , YanQuMessageUtils.buildMessage(GameProtocol.S_MONOPOLY_MARKET_GET_USER,MonopolyMarketMgr.getUserData(userId,serverId,userBaseInfo,decorationClass,decorationOverTime)));
    }

    @Override
    public void sendData() {

    }
}
